package compilador.GUIatipico;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTabbedPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class JVentanaPrincipal extends javax.swing.JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2894818932940075980L;
	private JMenu jMenu1;
	private JMenuItem jMenuItemSalir;
	private JPanelAFD jPanelAFD;
	private JTabbedPane jTabbedPane;
	private JMenuItem jMenuItemAbrir;
	private JMenuBar jMenuBar;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JVentanaPrincipal inst = new JVentanaPrincipal();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public JVentanaPrincipal() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jTabbedPane = new JTabbedPane();
				getContentPane().add(jTabbedPane);
				jTabbedPane.setBounds(0, 70, 1390, 618);
				{
				}
				{
					jPanelAFD = new JPanelAFD();
					jTabbedPane.addTab("AFDs", null, jPanelAFD, null);
				}
			}
			{
				jMenuBar = new JMenuBar();
				setJMenuBar(jMenuBar);
				{
					jMenu1 = new JMenu();
					jMenuBar.add(jMenu1);
					jMenu1.setText("Archivo");
					{
						jMenuItemAbrir = new JMenuItem();
						jMenu1.add(jMenuItemAbrir);
						jMenuItemAbrir.setText("Abrir");
						jMenuItemAbrir.addActionListener(new ActionListener() {
							public void actionPerformed(ActionEvent evt) {
								jMenuItemAbrirActionPerformed(evt);
							}
						});
					}
					{
						jMenuItemSalir = new JMenuItem();
						jMenu1.add(jMenuItemSalir);
						jMenuItemSalir.setText("Salir");
					}
				}
			}
			pack();
			this.setSize(1425, 815);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void jMenuItemAbrirActionPerformed(ActionEvent evt) 
	{
		JFileChooser fc = new JFileChooser();
		int returnVal = fc.showOpenDialog(this);

        if (returnVal == JFileChooser.APPROVE_OPTION) 
        {
            File file = fc.getSelectedFile();
            String codigo = "";
            BufferedReader entrada;
            
    		try 
    		{
    			entrada = new BufferedReader( new FileReader( file ) );
    			String linea;
    		
    			while((linea = entrada.readLine())!=null)
    			{
    				codigo += linea + "\n";
    			}
    			
    		}
    		catch (IOException e) 
    		{
    			e.printStackTrace();
    		}
        }
	}

}
